package com.yanze.schoolinformation.utils;

import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

import com.yanze.schoolinformation.R;

/**
 * Created by MrZheng on 2018/4/25.
 */

public class DialogBuild {

    /**
     * 显示当行文字的AlertDialog
     */
    public static void show(View v, String title, DialogInterface.OnClickListener clickListener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
        View view = View.inflate(v.getContext(), R.layout.view_title_doubantop, null);
        TextView titleTop = view.findViewById(R.id.title_top);
        titleTop.setText(title);
        builder.setView(view);
        builder.setPositiveButton("查看详情", clickListener);
        builder.show();
    }

    /**
     * 显示选项的AlertDialog
     */
    public static void showItems(final View v, final String content) {
        String[] items = {"复制", "分享"};
        AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
        builder.setItems(items, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0:
                        BaseTools.copy(content);
                        ToastUtils.show("复制成功");
                        break;
                    case 1:
                        ShareUtils.share(v.getContext(), content);
                        break;
                    default:
                        break;
                }
            }
        });
        builder.show();
    }
}
